home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
MCASM.RAR
/
MC_ASM.EXE
/
WROX_ASM
/
CH4
/
PROG4_2.ASM
< prev
next >
Wrap
Assembly Source File
|
1994-11-14
|
2KB
|
70 lines
************************************************************
Program 4.2 A Resident Beeper
************************************************************
cseg group cres,cinit
cres segment
assume cs:cseg
oldint8 dw 2 dup (?)
tik dw 0
int8 proc far
inc tik
cmp tik,1092 ; one minute
je sound_on
cmp tik,18 ; one second
je sound_off
jmp dword ptr oldint8
sound_on:
push ax
mov tik,0
in al,61h ; Get port setting
or al,3
out 61h,al : Turn speaker on
mov al,0b6h ; control word 0B6h (10110110b)
; switche channel 2 ofthe timer
; into mode 3,
; binary count,
; load least significant byte first,
; most significant byte next.
out 43h,al
mov al,9 ; 1.19/1709h Mhz (frequency divisor)
out 42h,al ; load low part
mov al,17h
out 42h,al ; load high part
pop ax
jmp dword ptr oldint8
sound_off:
push ax
in al,61h ; Get port setting
and al,0fch
out 61h,al ; Turn speaker off
pop ax
jmp dword ptr oldint8
int8 endp
cres ends
cinit segment
start:
push ds
mov ax,3508h
int 21h ; Get old Int 8 vector
mov oldint8,bx
mov oldint8+2,es
push cs
pop ds
lea dx,int8
mov ax,2508h
int 21h ; Set new Int 8 vector
pop dx
sub dx,cinit
neg dx ; Get # of paragraphs to keep
mov ax,3100h
int 21h ; Keep program in memory
cinit ends
end start